﻿<!doctype html>
<html><!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>会员车型分析</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/sub.js"></script><!-- 标签切换 -->
<script type="text/javascript" src="../js/gbRst.js"></script>
	<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/highcharts.js"></script>
<script type="text/javascript" src="../js/exporting_1.js"></script>
<script type="text/javascript" src="../js/huituUtils.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script> 
<link href="../css/style.css" type="text/css" rel="stylesheet" />

<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->


</head>

<body>
<!-- InstanceBeginEditable name="EditRegion3" -->
<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
<script type="text/javascript">
$(function(){	
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "0"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});
});
$(function(){
	$("#nowYear").change(function(){
		findMemberCount()
	})
})
//选年份的下拉框
</script>

<script type="text/javascript">
		var year = null
			
			$(document).ready(function() {
				var year = new Date()
					/* 	$.ajax({
						type : "get",
						datatype : "json",
						url : "../member/find/memberCount",
						data : {'year':year},
						success : function(data) {
							var rst = JSON.parse(data);
								if(rst.state==0){
									 	$("#allCount").html(rst.result.data[0][0])
									 	$("#yesCount").html(rst.result.data[0][1])
									}
						}	
					});
					
				var now=new Date();
				endTime=now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
				$("#dtEnd").val(endTime)	
				now.setTime(now.getTime()-30*24*3600*1000);
				beginTime=now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
				$("#dtBegin").val(beginTime)	 */
			
				findMemberCount();
				findMemberMCount();
			});
			
			
			function findMemberCount(){		
				/* var beginTime=$("#dtBegin").val();
				var endTime = $("#dtEnd").val();
				var param="timeBegin="+beginTime+"&timeEnd="+endTime; */
				$.ajax({
						type : "get",
						async:false,
						datatype : "json",
						data:{'year':year},
						url : "../member/find/memberCountByYearAndCarType",
						success : function(data) {
							var rst = JSON.parse(data);
									if(IsEmpty(rst)){
										art.dialog({fixed:true, lock: true,content:"查询错误",icon:'error',ok:true});	
										return false;
										}
										if(rst.state==0){
									makeParam(rst);
									}else if(rst.state==1){
									art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
									}else{
											checkStateShowErrorMsgAndDealResult(data);
									}			
									
									
						}	
					});
				
			}
			function findMemberMCount(){		
				/* var beginTime=$("#dtBegin").val();
				var endTime = $("#dtEnd").val();
				var param="timeBegin="+beginTime+"&timeEnd="+endTime; */
				$.ajax({
						type : "get",
						async:false,
						datatype : "json",
						data:{'year':year},
						url : "../member/find/memberCountByMonAndCarType",
						success : function(data) {
							var rst = JSON.parse(data);
									if(IsEmpty(rst)){
										art.dialog({fixed:true, lock: true,content:"查询错误",icon:'error',ok:true});	
										return false;
										}
										if(rst.state==0){
									makeParamM(rst);
									}else if(rst.state==1){
									art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
									}else{
											checkStateShowErrorMsgAndDealResult(data);
									}			
									
									
						}	
					});
				
			}
			
			function makeParam(json){
				var beginYear =2007
				var endYear = 2014
				var carType= new Array();
				for(m=0;m<json.result.data.length;m++){
					var CarTypeId = getHtmlInt(getHeadIndexValue(m, json, "carTypeId"));
					var isincarType = true;
					for ( var j = 0; j < carType.length; j++) {
						if(carType[j]==CarTypeId){
							isincarType = false;
						}
					}
					if(isincarType){
						carType.push(CarTypeId);
					}
					
				}
				var allYearBefor=0;
				var allYear2007=0;
				var allYear2008=0;
				var allYear2009=0;
				var allYear2010=0;
				var allYear2011=0;
				var allYear2012=0;
				var allYear2013=0;
				var allYear2014=0;
				var allcount = 0;
			for ( var j = 0; j < carType.length; j++) {
				var yearbefor = 0;
				var year2007 = 0;
				var year2008 = 0;
				var year2009 = 0;
				var year2010 = 0;
				var year2011 = 0;
				var year2012 = 0;
				var year2013 = 0;
				var year2014 = 0;
				var carName = 0;
				for(m=0;m<json.result.data.length;m++){
						var CarTypeId = getHtmlInt(getHeadIndexValue(m, json, "carTypeId"));
						
					if(CarTypeId == carType[j]){
						carName = getHtmlString(getHeadIndexValue(m, json, "cartypeN"));
						if(IsEmpty(carName)){
							carName="其它"
						}
						var year = getHtmlInt(getHeadIndexValue(m, json, "year"));
						var count = getHtmlInt(getHeadIndexValue(m, json, "count"));
						if(year<2007||IsEmpty(year)){
							allcount +=count;
							yearbefor += count;
							allYearBefor +=count;
						}else if(year==2007){
							allcount +=count;
						year2007 = count;
							allYear2007+=count;
						}else if(year==2008){
							allcount +=count;
							allYear2008+=count;
							year2008= count;
						}else if(year==2009){
							allcount +=count;
						allYear2009+=count;
						year2009= count;}
						else if(year==2010){
							allcount +=count;
						allYear2010+=count;
						year2010= count;
						}else if(year==2011){
							allcount +=count;
						allYear2011+=count;
						year2011= count;
						}else if(year==2012){
							allcount +=count;
						allYear2012+=count;
						year2012= count;
						}else if(year==2013){
							allcount +=count;
						allYear2013+=count;
						year2013= count;
						}else if(year==2014){
							allcount +=count;
						allYear2014+=count;
						year2014= count;
						}
					}
				}
				var allcarType = yearbefor+year2007+year2008+year2009+year2010+year2011+year2012+year2013+year2014
				var htm="<tr><td>"+carName+"</td><td>"+yearbefor+"</td><td>"+year2007+"</td><td>"+year2008+"</td><td>"+year2009+"</td><td>"+year2010+"</td><td>"+year2011+"</td><td>"+year2012+"</td><td>"+year2013+"</td><td>"+year2014+"</td><td>"+allcarType+"</td></tr>"
				$("#memberList1 tbody").prepend(htm)
				
			}
				$("#year_count_befor").html(allYearBefor)
				$("#year_count_2007").html(allYear2007)
				$("#year_count_2008").html(allYear2008)
				$("#year_count_2009").html(allYear2009)
				$("#year_count_2010").html(allYear2010)
				$("#year_count_2011").html(allYear2011)
				$("#year_count_2012").html(allYear2012)
				$("#year_count_2013").html(allYear2013)
				$("#year_count_2014").html(allYear2014)
				$("#all_count").html(allcount)
			}
			
			function makeParamM(json){
				var beginYear =2007
				var endYear = 2014
				var carType= new Array();
				for(m=0;m<json.result.data.length;m++){
					var CarTypeId = getHtmlInt(getHeadIndexValue(m, json, "carTypeId"));
					var isincarType = true;
					for ( var j = 0; j < carType.length; j++) {
						if(carType[j]==CarTypeId){
							isincarType = false;
						}
					}
					if(isincarType){
						carType.push(CarTypeId);
					}
					
				}
				var allYear1=0;
				var allYear2=0;
				var allYear3=0;
				var allYear4=0;
				var allYear5=0;
				var allYear6=0;
				var allYear7=0;
				var allYear8=0;
				var allYear9=0;
				var allYear10=0;
				var allYear11=0;
				var allYear12=0;
				var allcount = 0;
				var params =[];
			for ( var j = 0; j < carType.length; j++) {
				var yearbefor = 0;
				var year1= 0;
				var year2= 0;
				var year3 = 0;
				var year4 = 0;
				var year5 = 0;
				var year6 = 0;
				var year7 = 0;
				var year8 = 0;
				var year9 = 0;
				var year10 = 0;
				var year11 = 0;
				var year12 = 0;
				var carName = 0;
				var ms =0;
				for(m=0;m<json.result.data.length;m++){
						var CarTypeId = getHtmlInt(getHeadIndexValue(m, json, "carTypeId"));
						
					if(CarTypeId == carType[j]){
						carName = getHtmlString(getHeadIndexValue(m, json, "cartypeN"));
						if(IsEmpty(carName)){
							carName="其它"
						}
						var year = getHtmlInt(getHeadIndexValue(m, json, "year"));
						var count = getHtmlInt(getHeadIndexValue(m, json, "count"));
						if(year==1){
							allcount +=count;
							year1= count;
							allYear1 +=count;
						}else if(year==2){
							allcount +=count;
							year2 = count;
							allYear2 +=count;
						}else if(year==3){
							allcount +=count;
							year3 = count;
							allYear3 +=count;
						}else if(year==4){
							allcount +=count;
							year4 = count;
							allYear4 +=count;
						}else if(year==5){
							allcount +=count;
							year5 = count;
							allYear5 +=count;
						}else if(year==6){
							allcount +=count;
							year6 = count;
							allYear6 +=count;
						}else if(year==7){
							allcount +=count;
							year7 = count;
							allYear7 +=count;
						}else if(year==8){
							allcount +=count;
							year8 = count;
							allYear8 +=count;
						}else if(year==9){
							allcount +=count;
							year9 = count;
							allYear9 +=count;
						}
						else if(year==10){
							allcount +=count;
							year10 = count;
							allYear10 +=count;
						}
						else if(year==11){
							allcount +=count;
							year11 = count;
							allYear11 +=count;
						}else if(year==12){
							allcount +=count;
							year12 = count;
							allYear12 +=count;
						}
					}
				}
				var value = {'name':carName,'data':[year1,year2,year3,year4,year5,year6,year7,year8,year9,year10,year11,year12]}
				params[j]=value;
				var allcarType = year1+year2+year3+year4+year5+year6+year7+year8+year9+year10+year11+year12;
				var htm="<tr><td>"+carName+"</td><td>"+year1+"</td><td>"+year2+"</td><td>"
				+year3+"</td><td>"+year4+"</td><td>"+year5+"</td><td>"+year6+"</td><td>"+year7+"</td><td>"
				+year8+"</td><td>"+year9+"</td><td>"+year10+"</td><td>"+year11+"</td><td>"+year12+"</td><td>"+allcarType+"</td></tr>"
				$("#memberList2 tbody").prepend(htm)
				
			}
				$("#year_count_01").html(allYear1)
				$("#year_count_02").html(allYear2)
				$("#year_count_03").html(allYear3)
				$("#year_count_04").html(allYear4)
				$("#year_count_05").html(allYear5)
				$("#year_count_06").html(allYear6)
				$("#year_count_07").html(allYear7)
				$("#year_count_08").html(allYear8)
				$("#year_count_09").html(allYear9)
				$("#year_count_10").html(allYear10)
				$("#year_count_11").html(allYear11)
				$("#year_count_12").html(allYear12)
				$("#all_count_m").html(allcount)
				
				huitu_line("container1", params, "2014车辆统计", "数量", null, null)
			}
			
			function jisuan(num1,num2,xiaoshu){
				var c = num1/num2*100;
				return parseFloat(c).toFixed(xiaoshu)+"%"
			}
			/* function highChars(param,title,name){//绘图
			 var s=	new Highcharts.StockChart({
					chart: {
						renderTo: 'container1',
						marginRight: 30,
						marginBottom: 25
					},
				 credits:{
					 enabled :false
				 },
				 
					exporting:{
						enabled:false,
						show:false
					},
					rangeSelector: {
						show:false,
						enable:true,
				        buttons: [{
				            type: 'day',
				            count: 3,
				            text: '3天'
				        }, {
				            type: 'week',
				            count: 1,
				            text: '1周'
				        }, {
				            type: 'month',
				            count: 1,
				            text: '1个月'
				        }, {
				            type: 'month',
				            count: 6,
				            text: '6个月'
				        }, {
				            type: 'year',
				            count: 1,
				            text: '1年'
				        }, {
				            type: 'all',
				            text: '所有'
				        }],
				        selected: 6
				    },
					title: {
						text: title
						
					},
					subtitle: {
						text: ''
						
					},
					xAxis:{
			            labels: {  
			            formatter: function() {  
			                var vDate=new Date(this.value);  
			                return (vDate.getMonth()+1)+"-"+vDate.getDate();  
			            },
			            maxStaggerLines:3
						},
						minRange:7*24*3600*1000
						},
					yAxis: {
						title: {
							text: ''
						},
						plotLines: [{
							value: 0,
							width: 1,
							color: '#808080'
						}],
						min:0
					},
					 tooltip: {  
				            xDateFormat: '%Y-%m-%d'//鼠标移动到趋势线上时显示的日期格式  
				        },  
					legend: {
						layout: 'vertical',
						align: 'right',
						verticalAlign: 'top',
						x: -10,
						y: 100,
						borderWidth: 0
					},
					series: [{
						name: name,
						data: param,
						 pointInterval: 24*3600 * 1000,
					        tooltip: {
					        	valueSuffix: '人'
					        }
					}]
				});
			 	
			} */
				
	$(function(){
		$("#sub_s1").click(function(){
			findMemberCount(1)
			$("#search_btn2").hide()
			$("#search_btn1").show();
			$(this).addClass("focus");
			$("#sub_s2").removeClass("focus");
		})
		$("#sub_s2").click(function(){
			findMemberCount(2)
			$("#search_btn1").hide()
			$("#search_btn2").show();
			$(this).addClass("focus");
			$("#sub_s1").removeClass("focus");
		})
	})		
		</script><!-- 折线图 -->
<div class="container" id="container">
  <div class="container_R fr">
	<div class="place">会员车型分析</div>
    <!-- <div class="shadow yesterday_all">
    	<h2 class="title">会员统计</h2>
        <ul class="main_number">
        	<li class="noBorder"><strong >新会员</strong><span id="yesCount"></span></li>
        	<li><strong>总会员</strong><span id="allCount"></span></li>
        </ul>
        <div class="fc"></div>
    </div> -->
<!--     <div class="member_search"><select id="nowYear"></select></div>
 -->    <div class="shadow yesterday_all" id="bigBox">
<!--     	<h2 class="title">关键指标详解<div id="sub"><span class="focus" id="sub_s1">新增会员</span><span id="sub_s2">累积会员</span></div></h2>
 --><!--     	<div class="search_term"><span>起始日期：</span><input type="text" readonly class="doubledate ipticon"  id="dtBegin"/><span>截止时间：</span><input type="text" readonly class="doubledate ipticon" id="dtEnd"/><input type="button" id="search_btn1" class="search_btn common_btn" onclick="findMemberCount(1)" value="查询"><input type="button" id="search_btn2" style="display: none;" class="search_btn common_btn" onclick="findMemberCount(2)" value="查询"></div>
 -->        	<div class="box_img">
            	<h4>统计图</h4>
                <div class="line_img"><div id="container1" style="width: 100%; height: 400px; margin: 0 auto"></div></div>
            </div>
            
          <div>
           <table  width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList2">
 			<caption>
		<strong id="yearName">
		2014年</strong>
		</caption>   	<thead>
    	<tr >
        	<th >车型</th>
        	<th colspan="12"></th>
        	<th>小计</th>
        </tr>
        </thead>
    	<tbody>
    	<tr id="year">
    	<td>月份</td>
    	<td id="year_01">1月</td>
    	<td id="year_02">2月</td>
    	<td id="year_03">3月</td>
    	<td id="year_04">4月</td>
    	<td id="year_05">5月</td>
    	<td id="year_06">6月</td>
    	<td id="year_07">7月</td>
    	<td id="year_08">8月</td>
    	<td id="year_09">9月</td>
    	<td id="year_10">10月</td>
    	<td id="year_11">11月</td>
    	<td id="year_12">12月</td>
    	<td >合计</td>
    	</tr>
    	<tr id="rowCount">
    	<td>合计</td>
    	<td id="year_count_01"></td>
    	<td id="year_count_02"></td>
    	<td id="year_count_03"></td>
    	<td id="year_count_04"></td>
    	<td id="year_count_05"></td>
    	<td id="year_count_06"></td>
    	<td id="year_count_07"></td>
    	<td id="year_count_08"></td>
    	<td id="year_count_09"></td>
    	<td id="year_count_10"></td>
    	<td id="year_count_11"></td>
    	<td id="year_count_12"></td>
    	<td id="all_count_m"></td>
    	</tr>		
    	</tbody>
    </table>
     <table  width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList1">
     <caption>
		<strong id="yearName">
		全部</strong>
		</caption>
    	<thead>
    	<tr >
        	<th >车型</th>
        	<th colspan="9"></th>
        	<th>小计</th>
        </tr>
        </thead>
    	<tbody>
    	<tr id="year">
    	<td>年份</td>
    	<td id="year_befor">2007年以前</td>
    	<td id="year_2007">2007</td>
    	<td id="year_2008">2008</td>
    	<td id="year_2009">2009</td>
    	<td id="year_2010">2010</td>
    	<td id="year_2011">2011</td>
    	<td id="year_2012">2012</td>
    	<td id="year_2013">2013</td>
    	<td id="year_2014">2014</td>
    	<td >合计</td>
    	</tr>
    	<tr id="rowCount">
    	<td>合计</td>
    	<td id="year_count_befor"></td>
    	<td id="year_count_2007"></td>
    	<td id="year_count_2008"></td>
    	<td id="year_count_2009"></td>
    	<td id="year_count_2010"></td>
    	<td id="year_count_2011"></td>
    	<td id="year_count_2012"></td>
    	<td id="year_count_2013"></td>
    	<td id="year_count_2014"></td>
    	<td id="all_count"></td>
    	</tr>		
    	</tbody>
    </table>
          </div>   
        	   
    </div>
  </div>
  <div class="fc"></div>
</div>
<script type="text/javascript">

</script>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/header.js"></script>
<script type="text/javascript" src="../js/left.js"></script>
<script type="text/javascript" src="../js/footer.js"></script>
<script type="text/javascript">
showTab(9,2);
</script>
</body>
<!-- InstanceEnd --></html>
